package com.xzp.utils;

import com.xzp.entity.Result;
import com.xzp.enums.ResultEnum;

/**
 * @author Xbear
 *
 */
public class ResultUtil {

    public static Result success(Object object){
        Result result = new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    public static Result success(){
        return success(null);
    }

    /**
     * 错误方法
     * @param code 代码
     * @param msg 错误信息
     * @return
     */
    public static Result error(Integer code,String msg){

        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);

        return result;
    }
}
